﻿package org.openChart.sprite 
{
	import flash.display.DisplayObject;
	import flash.geom.Point;
	import flash.text.TextField;
	import org.openChart.display.DisplayElement;
	
	/**
	 * 
	 * @author Chongyuan
	 */
	public class ToolTipSprite extends BaseSprite 
	{
		private var position_:Point = new Point();
		
		private var textField:TextField = new TextField();
		
		public function ToolTipSprite( displayObject:DisplayElement, commandHandler:CommandHandler) 
		{
			super(displayObject,commandHandler);
			this.addChild(textField);
		}
		
		public override function paint():void
		{
			graphics.clear();
			fillRectangle(position_.x + 2, position_.y - 2, textField.textWidth + 10, 0 - textField.textHeight, 0xFFFFFF,1,0);
			drawRectangle(position_.x + 2, position_.y - 2, textField.textWidth + 10, 0 - textField.textHeight, 3, 0x333333, 1);
			textField.x = position_.x + 4;
			textField.y = position_.y - textField.textHeight - 4;
		}
		
		public function set x_(x:Number):void
		{
			position_.x = x;
		}
		
		public function set y_(y:Number):void
		{
			position_.y = y;
		}
		
		public function set position( position_:Point):void
		{
			this.position_ = position_;
		}
		
		public function set text(text_:String):void
		{
			textField.text = text_;
		}
	}
	
}